{% extends 'base.html' %}
{% block header %}
<script type="text/javascript">
    $(function () {
        var count = 0;
        $('#add_cart').on("click", function () {
            count += 1;
            $('#show_count').text(count);

        })
    })
</script>
{% endblock header%}
{% block body %}

    <div class="search_bar clearfix">
        <a href="/goods/index/" class="logo fl"><img src="/static/images/logo.png"></a>
        <div class="search_con fl">
            <form action="/search/" method="get">
                <input type="text" class="input_text fl" name="q" placeholder="搜索商品">
                <input type="submit" class="input_btn fr" name="" value="搜索">
            </form>
        </div>
        <div class="guest_cart fr">
            <a href="/cart/cart/" class="cart_name fl">我的购物车</a>
            <div class="goods_count fl" id="show_count">{{ request.session.totle }}</div>
        </div>
    </div>

	<div class="navbar_con">
		<div class="navbar clearfix">
			<div class="subnav_con fl">
				<h1>全部商品分类</h1>
				<span></span>
				<ul class="subnav">
					<li><a href="/goods/list1_1_1" class="fruit">新鲜水果</a></li>
					<li><a href="/goods/list2_1_1" class="seafood">海鲜水产</a></li>
					<li><a href="/goods/list3_1_1" class="meet">猪牛羊肉</a></li>
					<li><a href="/goods/list4_1_1" class="egg">禽类蛋品</a></li>
					<li><a href="/goods/list5_1_1" class="vegetables">新鲜蔬菜</a></li>
					<li><a href="/goods/list6_1_1" class="ice">速冻食品</a></li>
				</ul>
			</div>
			<ul class="navlist fl">
				<li><a href="/goods/index/">首页</a></li>
				<li class="interval">|</li>
				<li><a href="">手机生鲜</a></li>
				<li class="interval">|</li>
				<li><a href="">抽奖</a></li>
			</ul>
		</div>
	</div>

	<div class="breadcrumb">
		<a href="/goods/index/">全部分类</a>
		<span>></span>
		<a href="#">{{ typeinfo.type_name }}</a>
	</div>

	<div class="main_wrap clearfix">

    <!--
		<div class="l_wrap fl clearfix">
			<div class="new_goods">
				<h3>新品推荐</h3>
				<ul>
                    {% for goods in new_goods %}
					<li>
						<a href="/goods/detail_{{ typeinfo.id }}_{{ goods.id }}/"><img src="/static/{{ goods.goods_picture }}"></a>
						<h4><a href="/goods/detail_{{ goods.id }}/">{{ goods.goods_name }}</a></h4>
						<div class="prize">￥{{ goods.goods_price }}</div>
					</li>
                    {% endfor %}
				</ul>
			</div>
		</div>

		<div class="r_wrap fr clearfix">
			<div class="sort_bar">
				<a href="/goods/list{{typeinfo.id}}_1_1/"
                {% if sort == "1" %}
                class="active"
                {% endif %}
				>默认</a>
				<a href="/goods/list{{typeinfo.id}}_2_1/"
                {% if sort == "2" %}
                class="active"
                {% endif %}
				>价格</a>
				<a href="/goods/list{{typeinfo.id}}_3_1/"
                {% if sort == "3" %}
                class="active"
                {% endif %}
				>人气</a>
			</div>
-->
        {% if query %}
			<ul class="goods_type_list clearfix">
                {% for item in page %}
				<li>
					<a href="/goods/detail{{ item.object.goods_type_id }}_{{ item.object.id }}/"><img src="/static/{{ item.object.goods_picture }}"></a>
					<h4><a href="/item.object.detail{{ item.object.goods_type_id }}_{{ goods.id }}/">{{ item.object.goods_name }}</a></h4>
					<div class="operate">
						<span class="prize">￥{{ item.object.goods_price }}</span>
						<span class="unit">{{ item.object.goods_price }}/500g</span>
						<a href="/cart/add_{{item.object.id}}_1/" class="add_goods" id="add_cart" title="加入购物车"></a>
					</div>
				</li>
                {% endfor %}
			</ul>
        {% endif %}

			<div class="pagenation">
				{% if page.has_previous %}
				<a href="/search?q={{ query }}&page={{page.previous_page_number}}/">&lt;上一页</a>
				{% endif %}

				{% for index in paginator.page_range %}
                    {% if index %}
                        {% ifequal index page.number %}
                            <a href="#" class="active">{{ index }}</a>
                        {% else %}
                            <a href="/search?q={{ query }}&page={{index}}/">{{ index }}</a>
                        {% endifequal %}
                    {% else %}
                        <a>...</a>
                    {% endif %}
				{% endfor%}

				{% if page.has_next %}
				<a href="/search?q={{ query }}&page={{page.next_page_number}}/">下一页&gt;</a>
				{% endif %}
			</div>
		</div>
	</div>
{% endblock body %}

